#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail
set -o xtrace

STARTUP_DIR="$( cd "$( dirname "$0" )" && pwd )"

NAMESPACE=default
if [[ $# > 0 ]]; then
    NAMESPACE=$1
fi

CONTROLLER_VERSION=$(cat ${STARTUP_DIR}/engine/target/version.txt)
CONTROLLER_IMAGE_NAME=127.0.0.1:5000/seldonio/seldon-core-operator

ENGINE_VERSION=$(cat ${STARTUP_DIR}/engine/target/version.txt)
ENGINE_IMAGE_NAME=127.0.0.1:5000/seldonio/engine

helm install "${STARTUP_DIR}/helm-charts/seldon-core-operator" --name seldon-core \
     --set usageMetrics.enabled=true \
    --set image.pullPolicy=Always \
    --set image.repository=$CONTROLLER_IMAGE_NAME \
    --set image.tag=$CONTROLLER_VERSION \    
    --set engine.image.pullPolicy=Always \
    --set engine.image.repository=$ENGINE_IMAGE_NAME \
    --set engine.image.tag=$ENGINE_VERSION \
    --namespace seldon-system
helm install helm-charts/seldon-core-oauth-gateway --name seldon-gateway \
    --set serviceType=LoadBalancer \
     --namespace "${NAMESPACE}"
